﻿//Created by Action Script Viewer - http://www.buraks.com/asv
package Display.hud {
    import flash.events.*;

    public class HUDCapacityCounter extends HUDCounter {

        protected var m_targetCap:Number = 0;
        protected var m_targetRealValue:Number = 0;
        protected var m_currentRealValue:Number = 0;
        protected var m_realValueRate:Number = 0;

        public function HUDCapacityCounter(_arg1:Function){
            super(_arg1);
        }
        public function get capacity():Number{
            return (this.m_targetCap);
        }
        public function set capacity(_arg1:Number):void{
            if (_arg1 == this.m_targetCap){
                return;
            };
            this.m_targetCap = _arg1;
            m_targetValue = this.getTargetValue(this.m_targetRealValue, this.m_targetCap);
            m_startTimer = true;
        }
        override public function get value():Number{
            return (this.m_targetRealValue);
        }
        override public function set value(_arg1:Number):void{
            if (_arg1 == this.m_targetRealValue){
                return;
            };
            this.m_targetRealValue = _arg1;
            m_targetValue = this.getTargetValue(this.m_targetRealValue, this.m_targetCap);
            m_startTimer = true;
        }
        override public function update(_arg1:Boolean=false):void{
            if (_arg1){
                m_currentValue = m_targetValue;
                this.m_currentRealValue = this.m_targetRealValue;
                m_updateCallback(m_currentValue, this.m_currentRealValue);
            } else {
                if (m_startTimer){
                    m_changeRate = this.calculateChangeRateNumber(m_currentValue, m_targetValue);
                    this.m_realValueRate = calculateChangeRate(this.m_currentRealValue, this.m_targetRealValue);
                    m_updateTimer.start();
                };
            };
            m_startTimer = false;
        }
        override protected function updateCurrentValue(_arg1:TimerEvent):void{
            m_currentValue = (m_currentValue + m_changeRate);
            this.m_currentRealValue = (this.m_currentRealValue + this.m_realValueRate);
            if ((((((m_changeRate > 0)) && ((m_currentValue > m_targetValue)))) || ((((m_changeRate < 0)) && ((m_currentValue < m_targetValue)))))){
                m_currentValue = m_targetValue;
            };
            if ((((((this.m_realValueRate > 0)) && ((this.m_currentRealValue > this.m_targetRealValue)))) || ((((this.m_realValueRate < 0)) && ((this.m_currentRealValue < this.m_targetRealValue)))))){
                this.m_currentRealValue = this.m_targetRealValue;
            };
            m_updateCallback(m_currentValue, this.m_currentRealValue);
            if (m_currentValue == m_targetValue){
                m_updateTimer.reset();
                m_updateTimer.stop();
            };
        }
        protected function getTargetValue(_arg1:Number, _arg2:Number):Number{
            return ((_arg1 / _arg2));
        }
        protected function calculateChangeRateNumber(_arg1:Number, _arg2:Number):Number{
            return (((_arg2 - _arg1) / COUNT_RATE));
        }

    }
}//package Display.hud 
